# proto/Makefile

.PHONY: generate

# 定义protoc路径和插件
PROTOC := protoc
PROTOC_GEN_GO := $(shell go env GOPATH)/bin/protoc-gen-go
PROTOC_GEN_GRPC := $(shell go env GOPATH)/bin/protoc-gen-go-grpc

# 确保插件已安装
$(PROTOC_GEN_GO):
	go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28

$(PROTOC_GEN_GRPC):
	go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

# 生成Go代码
generate: $(PROTOC_GEN_GO) $(PROTOC_GEN_GRPC)
	$(PROTOC) \
		--go_out=../pkg/gobgp/proto \
		--go-grpc_out=../pkg/gobgp/proto \
		$(shell find ./gobgp/api -name "*.proto")